
var page = 1;
var userName = '',
    stateValue = '',
    code = '';


function doAjax(){
    $.ajax({
        url:'/crm/tiXianC/queryTiXianShenQingListCRM.json',
        dataType:'json',
        data:{
            token:localStorage.getItem('crmtoken'),
            page:page,
            userName:userName,
            code:code,
            stateValue:stateValue,
        },
        type:'post',
        success: function (data) {
            if(data.code==-1){
                window.parent.location.href="/crm/login.jsp"
            }
            if(data.code==0){
                alert(data.msg);
            }
            if(data.code==1){
                $('#record').html(data.recordsTotal);
                $('#withdraw-record').empty();
                for(var i=0;i<data.datas.length;i++){
                    $('<tr class="gradeA odd">'+
                        '<a href=""><td class="sorting_1 withdrawId" style="text-decoration: underline;cursor: pointer;">'+data.datas[i].id+'</td></a>'+
                        '<td class="center ">'+data.datas[i].accountName+'</td>'+
                        '<td class="sorting_1">'+data.datas[i].userName+'</td>'+
                        '<td class=" ">'+data.datas[i].bankName+'</td>'+
                        '<td class=" ">'+data.datas[i].money+'</td>'+
                        '<td class=" ">'+data.datas[i].factorage+'</td>'+
                        '<td class="center ">'+data.datas[i].state+'</td>'+
                        '<td class=" ">'+data.datas[i].createTime+'</td>'+
                        '<td class="center ">'+data.datas[i].code+'</td>'+
                        '<td class="center ">'+data.datas[i].handTime+'</td>'+
                        '</tr>').appendTo($('#withdraw-record'));
                }
                //id处理
                $('.withdrawId').click(function(){
                    var id = $(this).html();
                    var token = localStorage.getItem('token');
                    window.location.href="/crm/tiXianC/WithdrawalDetail?id="+id+"&token="+token;
                })
                $(".pagination").createPage({
                    totalPage:data.totalPage,
                    currPage:data.pageNow,
                    turndown:'true',
                    backFn:function(p){
                        page=p;
                        doAjax();
                    }
                });
            }
        }
    })
}

$(function(){
    doAjax();
})

//查询
$('#refer').click(function(){
    userName = $('#userName').val();
    code = $('#code').val();
    stateValue = $('#state').val();
    page=1;
    doAjax();
})

//处理


